<%#
name: Boot disk iPXE - generic static host
snippet: false
model: ProvisioningTemplate
kind: Bootdisk
description: |
  Generic host template with interactive static IP configuration. Tokens
  must be disabled in order to access templates via MAC addresses.
require:
- plugin: foreman_bootdisk
  version: 20.0.0
-%>
#!ipxe

<% (0..32).each do |i| -%>
:net<%= i %>
isset ${net<%= i -%>/mac} || goto configure
echo Found ${net<%= i -%>/mac} as net<%= i -%> on a ${net<%= i -%>/chip}
goto net<%= i+1 %>
<% end -%>

:configure
echo -n Interface (e.g. net0): && read interface
iseq ${interface} n && goto reboot ||
iseq ${interface} N && goto reboot ||

ifopen ${interface}
echo Please enter IPv4 details for ${interface}
echo

echo -n IP address:  && read ${interface}/ip
echo -n Subnet mask:  && read ${interface}/netmask
echo -n Default gateway:  && read ${interface}/gateway
echo -n DNS server:  && read dns

chain <%= bootdisk_chain_url %>${${interface}/mac} || goto reboot
exit 0

:reboot
echo Unable to continue, rebooting...
sleep 30
exit 1
